//---------------------------------------------------------------------------
#ifndef CPCtrlH
#define CPCtrlH
//---------------------------------------------------------------------------
#include "Outils.h"
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
#include <dbctrls.hpp>
//---------------------------------------------------------------------------
typedef struct {
  TColor Background;
  TColor Border;
} t_TitleColor;
//---------------------------------------------------------------------------
class CTree;
class CEICForm;
class CNodeInfos;
class PACKAGE_OUTILS CPageControl : public TCustomPanel
{
  private:
    CTree        *m_pCTree;    // Pointeur sur l'objet CTree associé
    int           m_nSpace;
    int           m_nHeader;   // Taille en pixels des onglets
    int           m_nMargin;
    TList        *m_TitleList;

    TSpeedButton *m_BtnNext;
    TSpeedButton *m_BtnPrev;
    TSpeedButton *m_BtnCustom;
    TComboBox    *m_pComboBox;

    bool m_EnCoursDeChangement;

    bool       __fastcall IsScreenListWithDisplayBar(void);
    int        __fastcall DetectOnglet(int xPos, int yPos);
    AnsiString __fastcall CutString( int nLengthTitleBar, int nXPos, const AnsiString &strText);
    AnsiString __fastcall GetFieldName( void) const;

    void       __fastcall EvComboBoxDropDown ( TObject *pSender);
    void       __fastcall EvComboBoxChange   ( TObject *pSender);
    void __fastcall EvComboBoxKeyDown(TObject *Sender,WORD &Key,TShiftState Shift);
    void       __fastcall EvComboBoxDrawItemEvent( TWinControl* pWinCtrl, int nIndex, const TRect &eRect, TOwnerDrawState eState);
    void       __fastcall OnClickNext        ( TObject *pSender);
    void       __fastcall OnClickPrev        ( TObject *pSender);
    void       __fastcall OnClickCustomSelect( TObject *pSender);

    void       __fastcall DrawOnglet( int nNumber, const AnsiString &strLevel, int WindowStyle, const AnsiString &strText);
    void       __fastcall SetHeader( int i);

  protected:
    virtual void __fastcall Paint(void);

    void __fastcall WMWindowPosChanged(TWMWindowPosChanged &Msg);
    void __fastcall WMLButtonDown(TWMLButtonDown &Msg);
    BEGIN_MESSAGE_MAP
      MESSAGE_HANDLER(WM_WINDOWPOSCHANGED, TWMWindowPosChanged, WMWindowPosChanged)
      MESSAGE_HANDLER(WM_LBUTTONDOWN     , TWMLButtonDown     , WMLButtonDown     )
    END_MESSAGE_MAP(TCustomControl)

  public:
     __fastcall  CPageControl(TComponent* Owner);
     virtual __fastcall ~CPageControl(void);

    int        __fastcall GetClientTop    (void);
    int        __fastcall GetClientHeight (void);
    int        __fastcall GetClientLeft   (void);
    int        __fastcall GetClientWidth  (void);

     void __fastcall AddTitle( CEICForm *pForm, CNodeInfos *nodeinfos);
     void __fastcall DeleteTitle(void);
     void __fastcall SetCTree( CTree *pCTree, Graphics::TBitmap *bmpPrev, Graphics::TBitmap *bmpNext, Graphics::TBitmap *bmpCustom);
     void __fastcall EvOnDataChange(TObject *Sender, TField *Field);
     void __fastcall Draw(void);

  __published:
    __property Align;
    __property Height;
    __property Left;
    __property Top;
    __property Width;
    __property Ctl3D;
    __property ParentCtl3D;
    __property ParentColor;

    __property int Header = { read=m_nHeader, write=SetHeader, default=27 };
    __property int Margin = { read=m_nMargin, write=m_nMargin, default=35 };
};
//---------------------------------------------------------------------------
#endif
